<?php
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use yii\widgets\LinkPager;
use frontend\controllers\MessageController;
use common\models\articles\Articles;
use common\models\member\Member;
use common\models\category\Category;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
    $tongzhi = Articles::find()->where(['category_id'=>18, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $zhengce = Articles::find()->where(['category_id'=>25, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $hangye = Articles::find()->where(['category_id'=>28, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $pinpai = Articles::find()->where(['category_id'=>23, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
    $xinwen = Articles::find()->where(['category_id'=>14, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(9)->all();
        // 会员风采
    $memberstyle = Member::find()->where(['status' => Member::STATUS_SUCCESS])->asArray()->limit(9)->all();
    $membersytletype = Category::find()->where(['id' =>20])->asArray()->one()['ctype'];

?>
<div class="content">
	<div class="w1113 bgd-ff mt10 mb10">
	    <span class="abwz">
		    您所在的位置：
		    <a href="<?= yii\helpers\Url::to(['/']);?>">首页</a> > 
		    <a href="<?= yii\helpers\Url::to(['message/index', 'id' => 63]); ?>"><?= '留言板'; ?></a> >
		    <a> <?= '我要留言'; ?></a>
	     </span>
	</div>
	<div class="w1113" style="background:#fff; padding:20px; width:1073px;">
     	<div class="ableft floatLeft">
            <div class="ablewidt">
                <h3 class="anh3"><?php echo $parenttitle; ?></h3>
                <div class="jquery-accordion-menu">
                    <ul  class="acb">
                    	<?php foreach($childcat as $t){ ?>
                        <li<?php if($id == $t['id']){echo ' class="active"';} ?>>
							<?php if(!empty($t['url'])){ ?>
                            <a href="<?= $t['url']; ?>"><?=$t['name']; ?></a>
                            <?php }else{ ?>
                            <a href="<?= yii\helpers\Url::to([$t['type'], 'id' => $t['id']]); ?>"><?=$t['name']; ?></a>
                            <?php  } ?>
                        </li>
                        <?php } ?>
                    </ul>
                </div>
            </div>
            <script type="text/javascript">
                jQuery(document).ready(function () {
                    jQuery(".jquery-accordion-menu").jqueryAccordionMenu();
                });
                $(function(){
                    //顶部导航切换
                    $(".acb li").click(function(){
                        $(".acb li.active").removeClass("active")
                        $(this).addClass("active");
                    })
                })
            </script>
        </div>
     	<div id="V_right" style="width:780px;">
	     
	     	<?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false, 'action' => 'sendpage' , 'method'=>'post' ]); ?>
	     	<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
	        	<div class="V_input V_jia">
	        		<p class="V_app" style=" font-size:16px; color:#666666; text-indent:20px;">为了您的留言得到及时有效处理和回应，请填写真实信息。我们将严格保护您的个人隐私。</p>
	                <p class="V_app"><label><font>*</font>昵称：</label><input id="user" name="user" type="text"></p>
	                <p class="V_app"><label><font>*</font>姓名：</label><input id="name" name="name" type="text"></p>
	                <p class="V_app"><label><font>*</font>联系电话：</label><input id="tel" name="phone" type="text"></p>
	                <p class="V_app"><label><font>*</font>电子邮件：</label><input id="mail" name="email" type="text"></p>
	                <p class="V_app"><label>所在企业：</label><input name="address" type="text"></p>
	                <p class="V_app"><label><font>*</font>标题：</label><input id="title" name="title" type="text"></p>
	                <p class="V_app"><label style="vertical-align:top;"><font>*</font>留言内容：</label><textarea name="content" id="text" maxlength="200">内容字数不超过200字！</textarea></p>
	                <p class="V_app" style="position: relative;"><label><font>*</font>验证码：</label>
		                <input style="width:195px;" name="code" placeholder="验证码" id="yan" class="a" type="text">
		                <?= Captcha::widget(['name'=>'verifyCode','captchaAction'=>'message/captcha','imageOptions'=>['id'=>'login_code', 'title'=>'换一个', 'alt'=>'换一个', 'style'=>'cursor:pointer;margin-left:25px;position: absolute;left: 370px;top: -5px;border: 1px #ccc solid;'],'template'=>'{image}']);?>
	                </p>
	                <div class="V_app">
	                    <div class="updiv" style="width:510px;">
	                          <input id="click" type="button" onclick="mytry()" value="提交" class="up_sub" />
	                    </div>
	                </div>
	        	</div>
	       <?php ActiveForm::end(); ?>
    	</div>
    <div style="clear:both"></div>
</div>
<script>  
    function refreshCode(obj) {  
        var url = $(obj).attr('data-api');  
  
        if (url) {  
            $.ajax({  
                url: url + '?refresh',  
                dataType: 'json',  
                type: 'get',  
                success: function(data) {  
                    $(obj).attr('src', data.url);  
                }  
            });  
        }  
      }  
    $(function (){
        refreshCode('#login_code');  
  
        $('#login_code').click(function (event) {  
            event.preventDefault();  //阻止默认行为  
            event.stopPropagation(); //该方法将停止事件的传播，阻止它被分派到其他 Document 节点  
  
            refreshCode(this);  
        });  
  
    });  
</script>
<script>
	function mytry(){
	   var user = $("#user").val();
	   var name = $("#name").val();
	   var tel = $("#tel").val();
	   var mail = $("#mail").val();
	   var title = $("#title").val();
	   var code = $("#yan").val();
	   var text = $("#text").val();
	   var sfenzheng=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
	   var try_email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	   
	   
	   if(user==""){
	    alert("请填写昵称！");
		return false;
	   }
	   
	   if(name==""){
	    alert("请填写姓名！");
		return false;
	   }
	   
	   if(tel==''){
	    alert("请填写正确的电话！");
		return false;
	   }
	   
	   if(mail=='' || !try_email.test(mail)){
	    alert("请填写正确的邮件！");
		return false;
	   }

	   if(title==''){
	    alert("请填写的标题！");
		return false;
	   }

	   if(text==''){
	    alert("请填写留言！");
		return false;
	   }

	   if(code==""){
	    alert("请填写验证码！");
		return false;
	   }

	   $('#login-form').submit();
	}
</script>